package com.xs.valid.demo.web;

import com.xs.valid.demo.annotation.JsonBeanAnnotation;
import com.xs.valid.demo.common.ResultJson;
import com.xs.valid.demo.common.ResultUtils;
import com.xs.valid.demo.entity.User;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author xs
 * date 2017/11/28 9:59
 */
@RestController
public class HelloController {
    @PostMapping("hello")
    public ResultJson hello(@Valid User user, BindingResult result) {
        // 调用业务层  xxxService
        System.out.println("执行  xxxService");
        return ResultUtils.success(user);

    }

    @PostMapping("hi")
    @JsonBeanAnnotation(classType = "com.xs.valid.demo.entity.User")
    public ResultJson hi(@RequestParam("dateJson") String dateJson,User user) {
        // 调用业务层  xxxService
        System.out.println("执行  hi service");
        return ResultUtils.success(dateJson);

    }

}